package org.example.modules.AliOSS;

/**
 * @Description FileUploadControlle
 * @Author xiaotian
 * @Date 2025-04-04
 */
import org.example.common.utils.OSSUtil;
import org.example.modules.AliOSS.sevice.FileUploadSevice;
import org.example.modules.user.common.Commsult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/wxApi/oss")
public class FileUploadController {

    @Autowired
    private FileUploadSevice fileUploadSevice;

    /**
     * 上传头像接口
     *
     * @param file 上传的文件
     * @return 文件的访问 URL
     */
    @PostMapping("/uploadAvatar")
    public Commsult<String> uploadAvatar(@RequestParam("file") MultipartFile file) {
        if (file.isEmpty()) {
            return Commsult.fail("文件为空");
        }
        return Commsult.success(fileUploadSevice.uploadImg(file));

    }
    /**
     * 上传头像接口
     *
     * @param file 上传的文件
     * @return 文件的访问 URL
     */
    @PostMapping("/uploadAvatar1")
    public Commsult<String> uploadAvatar1(@RequestParam("file") MultipartFile file) {
        if (file.isEmpty()) {
            return Commsult.fail("文件为空");
        }
        return Commsult.success(fileUploadSevice.uploadImg1(file));

    }
}
